package com.guldan.test.util;

/**
 * Created by Silas.
 * Date: 2017/2/20
 * Time: 0:01
 */

import java.io.*;

import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WriteException;
import org.apache.poi.hssf.usermodel.*;

public class ZoomSheet {

    public ZoomSheet() {
    }

    public static void main(String args[])
            throws IOException, WriteException {

        String strText = "测试写入Excel文本换行\r\n换行后的值";


        HSSFWorkbook wb = new HSSFWorkbook();

        HSSFCellStyle bodyStyle = wb.createCellStyle();
        bodyStyle.setWrapText(true);


        HSSFSheet sheet = wb.createSheet("测试文本值换行");

        sheet.setColumnWidth(0, 50 * 256);
        sheet.setColumnWidth(1, 25 * 256);

        HSSFRow row = sheet.createRow(1);
        HSSFCell cellNum = row.createCell(0);
        cellNum.setCellStyle(bodyStyle);

        cellNum.setCellValue(new HSSFRichTextString(strText));


        FileOutputStream fileOut = new FileOutputStream("D:/workbook.xls");
        wb.write(fileOut);
        fileOut.close();
    }
}